home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
C
/
paralleltest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-01-07
|
2KB
|
112 lines
/* parallel test program v1.1 */
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/ports.h"
#include "exec/libraries.h"
#include "exec/devices.h"
#include "exec/io.h"
#include "devices/parallel.h"
struct IOExtPar IORpar;
struct MsgPort *port;
char buffer[64000];
extern struct MsgPort *CreatePort();
main()
{
int error;
int actual;
unsigned char pflags;
unsigned long pt0;
unsigned long pt1;
open:
/* OPEN the parallel.device */
if ((error = OpenDevice (PARALLELNAME, 0, &IORpar, 0)) != 0) {
printf ("bad news %ld on Open \n", error);
exit (error);
}
/* SET UP the message port in the I/O request */
port = CreatePort (PARALLELNAME,0);
IORpar.IOPar.io_Message.mn_ReplyPort = port;
/* SET PARAMS for the parallel.device */
pflags = PARF_EOFMODE;
pt0 = 0x51040303;
pt1 = 0x03030303;
if ((error = setparams (pflags,pt0,pt1)) != 0) {
printf ("bad news %ld on setup \n", error);
exit (error); /* redundant err msg, but who's counting ?? */
}
actual = readPar (buffer,60000);
/* CLOSE the parallel.device */
CloseDevice (&IORpar);
DeletePort (port);
exit (0);
}
/* PARALLEL I/O functions */
setparams(pf,ta0,ta1)
unsigned char pf;
unsigned long ta0;
unsigned long ta1;
{
int error;
IORpar.io_ParFlags = pf;
IORpar.IOPar.io_Command = PDCMD_SETPARAMS;
IORpar.io_PTermArray.PTermArray0 = ta0;
IORpar.io_PTermArray.PTermArray1 = ta1;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device setparams error %ld \n", error);
exit (1);
}
return (error);
}
readPar(data,length)
char *data;
ULONG length;
{
int error;
IORpar.IOPar.io_Data = data;
IORpar.IOPar.io_Length = length;
IORpar.IOPar.io_Command = CMD_READ;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device read error %ld \n", error);
exit (1);
}
return (IORpar.IOPar.io_Actual);
}
writePar(data,length)
char *data;
int length;
{
int error;
IORpar.IOPar.io_Data = data;
IORpar.IOPar.io_Length = length;
IORpar.IOPar.io_Command = CMD_WRITE;
if ((error = DoIO (&IORpar)) != 0) {
printf ("parallel.device write error %ld \n", error);
exit (1);
}
return (error);
}